package operator.create;

import java.util.concurrent.Callable;

import io.reactivex.Observable;
import io.reactivex.ObservableSource;

class DeferOperator {
    public static void main(String[] args) {
        defer();
    }

    //直到被观察者被订阅才创建被观察者
    //1.推迟创建时机，懒加载
    //2.动态生成Obserable
    static void defer(){
        Observable.just(1).subscribe();
        Observable.defer(new Callable<ObservableSource<?>>() {
            @Override
            public ObservableSource<?> call() throws Exception {
                return Observable.just(1);
            }
        }).subscribe();
    }
}
